/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agh.air.bpel2bpmn.comparator.impl;

import org.agh.air.bpel2bpmn.comparator.AbstractComparator;
import org.agh.air.bpel2bpmn.exception.PatternNotFoundException;
import org.w3c.dom.Node;

/**
 *
 * @author paletz
 */
public class ParallelSplitComparator extends AbstractComparator {

    /* <process>
    <flow>
    <invoke name="Task2"/>
    <invoke name="Task3"/>
    </flow>
    </process>
     */
    @Override
    public String compare(Node node) throws PatternNotFoundException {

        if (node.getNodeName().equals(FLOW)) {

            String str = "parallel_split" + LTMP;
            for (int i = 0; i < node.getChildNodes().getLength(); i++) {
                if (getIChild(node, i).getNodeName().equals(INVOKE)) {
                    str = str + getNameAttribute(getIChild(node, i));
                } else {
                    str = str + getIChild(node, i).getNodeName();
                }

                if (i != node.getChildNodes().getLength() - 1) {
                    str = str + ".";
                }
            }

            return str + RTMP;
        }

        throw new PatternNotFoundException();
    }
}
